<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<spring:hasBindErrors name="vehicleHistory">
<div id='error'>
    <span>
	<c:forEach items="${errors.allErrors}" var="error">
		<spring:message code="${error.code}" text="${error.defaultMessage}"/>
	</c:forEach>
    </span>
    <a href="#" class="close-notify">X</a>
</div>
</spring:hasBindErrors>
<form:form method="POST" commandName="vehicle">
	<center>
		<table>
		<c:forEach items="${vehicle.history}" var="i" varStatus="itemsRow">
			<tr>
				<td align="right" width="20%">Event date:</td>
				<td style="width: 20%"><form:input path="history[${itemsRow.index}].eventDate"/></td>
				<td><font color="red"><form:errors path="history[${itemsRow.index}].eventDate" /></font></td>
			</tr>
			<tr>
				<td align="right" width="20%">Location:</td>
				<td style="width: 20%"><form:input path="history[${itemsRow.index}].eventLocation"/></td>
				<td><font color="red"><form:errors path="history[${itemsRow.index}].eventLocation" /></font></td>
			</tr>
			<tr>
				<td align="right" width="20%">Odometer reading:</td>
				<td style="width: 40%"><form:input path="history[${itemsRow.index}].reading" /></td>
				<td><font color="red"><form:errors path="history[${itemsRow.index}].reading" /></font></td>
			</tr>
			<tr>
				<td align="right" width="20%">Data Source:</td>
				<td style="width: 40%">
					<form:select path="history[${itemsRow.index}].dataSource">
						<form:option value="">Select...</form:option>
						<form:option value="Motor Vehicle Dept">Motor Vehicle Dept.</form:option>
						<form:option value="Auto Auction"/>
						<form:option value="Independent Emission Source"/>
						<form:option value="Other"/>
					</form:select>
				</td>
				<td><font color="red"><form:errors path="history[${itemsRow.index}].dataSource" /></font></td>
			</tr>
			<tr>
				<td align="right" width="20%">Details:</td>
				<td style="width: 40%"><form:textarea path="history[${itemsRow.index}].details"/></td>
				<td><font color="red"><form:errors path="history[${itemsRow.index}].details" /></font></td>
			</tr>
		</c:forEach>
			<tr>
				<td>&nbsp;</td>
				<td colspan="2">
					<input type="submit" name="_cancel" value="Cancel" />
					<input type="submit" name="_target0" value="Back" />
					<input type="submit" name="_target2" value="Next" />
				</td>
			</tr>
		</table>
	</center>
</form:form>